﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class FindGivenSumInArray
{
    static void Main()
    {
        Console.Write("Array size:");
        int arraySize = int.Parse(Console.ReadLine());
        int[] array = new int[arraySize];
        Console.Write("Targeted sum:");
        int targetSum = int.Parse(Console.ReadLine());

        for (int i = 0; i < arraySize; i++)
        {
            Console.Write("\nElement a[{0}]:", i);
            array[i] = int.Parse(Console.ReadLine());
        }

        //int[] array = { 4, 3, 1, 4, 2, 5, 8 };
        //int targetSum = 11;

        for (int i = 0; i < array.Length; i++)
        {
            int candidateSum=0;

            for (int j = i; j < array.Length; j++)
            {
                candidateSum += array[j];
                if (candidateSum==targetSum)
                {
                    Console.Write("Numbers are :"+array[i]);
                    for (int k = i+1; k <= j; k++)
                    {
                        Console.Write("+"+array[k]);
                    }
                    Console.WriteLine("="+candidateSum);
                }
            }
        }
    }

}